When performing mixed changes on fields, i.e. changing fields in a NotesUiDocument and others in the corresponding backend NotesDocument, it is very important to make sure that they do not have any side-effects on each other. Could be ugly...
To see what I mean, try this one:
Build a simple form with one text-field "myField" and a button. The button has the following code in the Click event:
' get NotesUiDocument
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
' first check the current content in the field
Msgbox uidoc.FieldGetText("myField")
' change the field content in the uiDoc and show us, that it was successful
Call uidoc.FieldSetText("myField", "my new content")
Msgbox uidoc.FieldGetText("myField")
' now change a totally different field (item) in the backend document
Call uidoc.Document.ReplaceItemValue("xy", "1")
' oops... what happened to my ui changes?
Msgbox uidoc.FieldGetText("myField")
Now open the form in Notes and fill the field with some content. The button *should* do the following (that is what I would expect):
- Display the current field content in an alert
- Change the field content in the uiDocument and display the new content
- Add a new item "xy" with the value "1" in the backend
- Display an alert with the new content of the ui field
Well, *this* is what it actually does:
- Display the current field content in an alert
- Change the field content in the uiDocument and display the new content
- Add a new item "xy" with the value "1" in the backend
- Display an alert with the original content of the ui field (same one as in the last alert)
The change in the backend seems to make Notes reload the NotesUiDocument; it is not a real reload, because none of the events is triggered; maybe Notes just forgets the changes in the UI. Whatever it is, the changes in the UI will be lost. -- Mixing UI field changes and backend changes in Notes: not a good idea...
About the Author
Marcus Foerster works as Systems Architect for Pentos AG in Munich, Germany. His focus lies on the application side, creating collaboration systems for users, groups and enterprises to get their daily work done. This approach includes integrating complex workflows with intuitive user interfaces, using Lotus Notes/Domino with Adobe Flex and other Web technologies.
Read more in Marcus' blog: http://marcus.foerster.com/blog